﻿/* Author:
 *  Andrea Vandin
 */
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace TripLOAMobile.InternalEntities
{

    /// <summary>
    /// This class represents the generic informations of a travel
    /// </summary>
    public class TravelInfoContainer
    {
        protected string departure, destination;
        protected double latDep, latDes, longDep, longDes;
        protected AddressFields departureFields, destinationFields;

        protected bool areDepLatLongDefined, areDesLatLongDefined;
        private bool smoker;


        /// <summary>
        /// Initializes a new instance of the <see cref="TravelInfoContainer"/> class.
        /// </summary>
        public TravelInfoContainer()
            : base()
        {
            departureFields = new AddressFields();
            destinationFields = new AddressFields();
            areDepLatLongDefined = false;
            areDesLatLongDefined = false;
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="TravelInfoContainer"/> class.
        /// </summary>
        /// <param name="departureAddres">The departure addres.</param>
        /// <param name="destinationAddres">The destination addres.</param>
        /// <param name="smokerAccepted">if set to <c>true</c> [smoker accepted].</param>
        public TravelInfoContainer(string departureAddres, string destinationAddres, bool smokerAccepted):this()
        {
            Departure = departureAddres;
            Destination = destinationAddres;
            Smoker = smokerAccepted;
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="TravelInfoContainer"/> class.
        /// </summary>
        /// <param name="smokerAccepted">if set to <c>true</c> [smoker accepted].</param>
        public TravelInfoContainer(bool smokerAccepted):this()
        {
            Smoker = smokerAccepted;
        }


        /// <summary>
        /// Gets or sets the departure.
        /// </summary>
        /// <value>The departure.</value>
        public string Departure
        {
            get
            {
                if (departure == null)
                    return "";
                else
                    return departure;
            }
            set
            {
                departure = value;
            }
        }

        /// <summary>
        /// Gets or sets the destination.
        /// </summary>
        /// <value>The destination.</value>
        public string Destination
        {
            get
            {
                if (destination == null)
                    return "";
                else
                    return destination;
            }
            set
            {
                destination = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="TravelInfoContainer"/> accept smokers.
        /// </summary>
        /// <value><c>true</c> if smoker; otherwise, <c>false</c>.</value>
        public bool Smoker
        {
            get
            {
                return smoker;
            }
            set
            {
                smoker = value;
            }
        }


        /// <summary>
        /// Sets the departure, utlizing all the parameters
        /// </summary>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="province">The province.</param>
        /// <param name="zipcode">The zipcode.</param>
        /// <param name="state">The state.</param>
        public void setReadableDeparture(string street, string city, string province, string zipcode, string state)
        {
            departureFields = new AddressFields(street, city, province,zipcode, state);
            departure = departureFields.getReadableString();
        }

        /// <summary>
        /// Sets the destination, utilizing all the parameters
        /// </summary>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="province">The province.</param>
        /// <param name="zipcode">The zipcode.</param>
        /// <param name="state">The state.</param>
        public void setReadableDestination(string street, string city, string province,string zipcode, string state)
        {
            destinationFields = new AddressFields(street, city, province,zipcode, state);
            destination = destinationFields.getReadableString();
        }

        /// <summary>
        /// Gets the departure in format "street,[zipcode] city [province],state".
        /// </summary>
        /// <returns></returns>
        public string getDepartureInFormat()
        {
            string cityApp = (departureFields.ZipCode != null && departureFields.ZipCode != "") ? (departureFields.ZipCode + " ") : "";
            cityApp += departureFields.City;
            cityApp += (departureFields.Province != null && departureFields.Province != "") ? (" " + departureFields.Province) : "";

            return departureFields.Street + "," + cityApp + "," + departureFields.ZipCode + "," + departureFields.State;
        }

        /// <summary>
        /// Gets the destination in format "street,[zipcode] city [province],state".
        /// </summary>
        /// <returns></returns>
        public string getDestinationInFormat()
        {
            string cityApp = (destinationFields.ZipCode != null && destinationFields.ZipCode != "") ? (destinationFields.ZipCode + " ") : "";
            cityApp += destinationFields.City;
            cityApp+= (destinationFields.Province != null && destinationFields.Province != "") ? (" " + destinationFields.Province) : "";

            return destinationFields.Street + "," + cityApp + "," + destinationFields.ZipCode + "," + destinationFields.State;
        }


        /// <summary>
        /// Gets the departure fields.
        /// </summary>
        /// <value>The departure fields.</value>
        public AddressFields DepartureFields
        {
            get
            {
                return departureFields;
            }
        }

        /// <summary>
        /// Gets the destination fields.
        /// </summary>
        /// <value>The destination fields.</value>
        public AddressFields DestinationFields
        {
            get
            {
                return destinationFields;
            }
        }


        /// <summary>
        /// Sets all lat and long.
        /// </summary>
        /// <param name="latDep">The lat dep.</param>
        /// <param name="longDep">The long dep.</param>
        /// <param name="latDes">The lat DES.</param>
        /// <param name="longDes">The long DES.</param>
        public void setAllLatLong(double latDep, double longDep, double latDes, double longDes)
        {
            this.areDepLatLongDefined = true;
            this.areDesLatLongDefined = true;
            this.latDep = latDep;
            this.latDes = latDes;
            this.longDep = longDep;
            this.longDes = longDes;
        }

        /// <summary>
        /// Sets the departure latitude and longitude.
        /// </summary>
        /// <param name="latDep">The lat dep.</param>
        /// <param name="longDep">The long dep.</param>
        public void setDepLatLong(double latDep, double longDep)
        {
            this.areDepLatLongDefined = true;
            this.latDep = latDep;
            this.longDep = longDep;
        }


        /// <summary>
        /// Sets the destination latitude and longitude.
        /// </summary>
        /// <param name="latDes">The lat DES.</param>
        /// <param name="longDes">The long DES.</param>
        public void setDesLatLong(double latDes, double longDes)
        {
            this.areDesLatLongDefined = true;
            this.latDes = latDes;
            this.longDes = longDes;
        }


        /// <summary>
        /// Gets a value indicating whether [are all lat long defined].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [are all lat long defined]; otherwise, <c>false</c>.
        /// </value>
        public bool AreAllLatLongDefined
        {
            get
            {
                return areDepLatLongDefined && areDesLatLongDefined;
            }
        }

        /// <summary>
        /// Gets a value indicating whether [are dep lat long defined].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [are dep lat long defined]; otherwise, <c>false</c>.
        /// </value>
        public bool AreDepLatLongDefined
        {
            get
            {
                return areDepLatLongDefined;
            }
        }

        /// <summary>
        /// Gets a value indicating whether [are DES lat long defined].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [are DES lat long defined]; otherwise, <c>false</c>.
        /// </value>
        public bool AreDesLatLongDefined
        {
            get
            {
                return areDesLatLongDefined;
            }
        }

        /// <summary>
        /// Sets the dep lat long NOT defined.
        /// </summary>
        public void setDepLatLongNOTDefined()
        {
            areDepLatLongDefined = false;
        }

        /// <summary>
        /// Sets the DES lat long NOT defined.
        /// </summary>
        public void setDesLatLongNOTDefined()
        {
            areDesLatLongDefined = false;
        }

        /// <summary>
        /// Gets the dep lat long string.
        /// </summary>
        /// <returns></returns>
        public string getDepLatLongString()
        {
            return latDep + "," + longDep;
        }

        /// <summary>
        /// Gets the DES lat long string.
        /// </summary>
        /// <returns></returns>
        public string getDesLatLongString()
        {
            return latDes + "," + longDes;
        }

        /// <summary>
        /// Gets the lat dep.
        /// </summary>
        /// <value>The lat dep.</value>
        public double LatDep
        {
            get
            {
                return latDep;
            }
        }

        /// <summary>
        /// Gets the lat DES.
        /// </summary>
        /// <value>The lat DES.</value>
        public double LatDes
        {
            get
            {
                return latDes;
            }
        }

        /// <summary>
        /// Gets the long dep.
        /// </summary>
        /// <value>The long dep.</value>
        public double LongDep
        {
            get
            {
                return longDep;
            }
        }

        /// <summary>
        /// Gets the long DES.
        /// </summary>
        /// <value>The long DES.</value>
        public double LongDes
        {
            get
            {
                return longDes;
            }
        }


    }
}
